#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:11操作mysql数据库查询数据.py
# author: 马国鑫
# datetime:2022/4/17 22:07
# software: PyCharm

"""
this is function  description 
"""

# import module your need

import pymysql
conn = pymysql.connect(host='localhost', user='root',
                       password='021207', database='python_db', port=3306)

cur = conn.cursor()

sql = 'select * from t_student'


try:
    cur.execute(sql)
    student = cur.fetchone()
    # print(students)
    sno = student[0]
    sname = student[1]
    age = student[2]
    score = student[3]
    print('sno:', sno, 'sname:',sname, 'age:',age, 'score:', score)
except Exception as e:
    print(e)
    print('查询所有数据失败')
finally:
    cur.close()
    conn.close()